/* eslint-disable */
import vue from 'vue'
import Toast from './Toast.vue'

const ToastConstructor = vue.extend(Toast)

const ToastDom = new ToastConstructor({
  el: document.createElement('div'),
  data () {
    return {
      isShow: false,
      msg: ''
    }
  }
})

document.body.appendChild(ToastDom.$el)

function $toast (msg, time = 2000) {
  ToastDom.msg = msg || 'test'
  console.log(msg)
  ToastDom.isShow = true
  setTimeout(() => {
    ToastDom.isShow = false
  }, time)
}

export default function install (Vue) {
  Vue.prototype.$toast = $toast
}
